package com.anbang.website.service;

import java.util.Map;

import com.google.common.collect.Maps;

import net.sf.json.JSONObject;

/**
 * @author peepul
 *
 * 购物车处理助手helper
 */
public class ShoppingCartHelper {

	/**
	 * 清空整个购物车
	 * 
	 * @return
	 */
	public static JSONObject clearCart() {
		return ServiceHelper.get(ServiceDefine.SVR_CART_CLEAR, "");
	}
	
	/**
	 * 移除指定的商品从购物车中
	 * 
	 * @param id
	 * @return
	 */
	public static JSONObject delFromCart(Long id){
		return ServiceHelper.get(ServiceDefine.SVR_CART_REMOVE, String.valueOf(id));
	}	
	
	/**
	 * 增加商品到购物车
	 * 
	 * @param prodId
	 * @param num
	 * @param logUserId
	 * @param customerId
	 * @return
	 */
	public static JSONObject addToCart(String prodId, String num, String logUserId, Long customerId){
		//构造map
		Map<String, Object> map = Maps.newHashMap();
		map.put("prodId", prodId);
		map.put("num", num);
		map.put("logUserId", logUserId);
		map.put("customerId", customerId);
		
		return ServiceHelper.post(ServiceDefine.SVR_CART_ADD, map);
	}
	
	/**
	 * 我的购物车商品列表
	 * 
	 * @param loginUserId
	 * @return
	 */
	public static JSONObject myShopCart(Long loginUserId){
		return ServiceHelper.post(ServiceDefine.SVR_CART_LIST, String.valueOf(loginUserId));
	}

}

